<?php        
        require_once('../inc/models/orders_model.php');
        if(isset($_POST['submit']))
        {        	
                $row = $_POST;
                SaveOrder($row);                
                header("Location: index.php");       
        }
        else
        {                $results = GetOrder($_REQUEST['id']);
				$customer = GetCustomers();	
						
        }
?>
<!DOCTYPE html>
<html lang="en">
        <?php include('../inc/header.php'); ?>
        <body>
        <?php include('../inc/navigation.php'); ?>
        <div class="span9">
        	<div class="row-fluid">
            	<h2>Edit Order</h2>                        
				<form class="form-horizontal" method="post" action="#">
                	<input type="hidden" name="id" value="<?=$results['id']?>" />
                    <div class="control-group">
                       	<label class="control-label" for="customer_id">Customer:</label>
                       	<div class="controls">
                       		<select name="customer_id" id = "customer_id">
                       			<? while($rs = $customer->fetch_assoc()): ?>
                       				<option value="<?=$rs['id']?>"><?=$rs['FirstName']?> <?=$rs['LastName']?></option>
                        		<?php endwhile; ?>                        		                    		
                        	</select>                        	                            	
                        </div>
                    </div>                     
                    <div class="control-group">
						<label class="control-label" for="amount">Amount:</label>
						<div class="controls">
							<input type="text" name="amount" id="amount" value="<?=$results['amount']?>"/>
						</div>
					</div> 
					<div class="control-group">
						<label class="control-label" for="address">Address:</label>
						<div class="controls">
							<input type="text" name="address" id="address" value="<?=$results['address']?>"/>
						</div>
					</div> 
					<div class="control-group">
						<label class="control-label" for="city">City:</label>
						<div class="controls">
							<input type="text" name="city" id="city" value="<?=$results['city']?>"/>
						</div>
					</div> 
					<div class="control-group">
						<label class="control-label" for="state">State:</label>
						<div class="controls">
							<input type="text" name="state" id="state" value="<?=$results['state']?>"/>
						</div>
					</div> 
					<div class="control-group">
						<label class="control-label" for="zip">Zip Code:</label>
						<div class="controls">
							<input type="text" name="zip" id="zip" value="<?=$results['zip']?>"/>
						</div>
					</div> 
					<div class="control-group">
						<label class="control-label" for="country">Country:</label>
						<div class="controls">
							<input type="text" name="country" id="country" value="<?=$results['country']?>"/>
						</div>
					</div> 
					<div class="control-group">
						<label class="control-label" for="phone">Phone:</label>
						<div class="controls">
							<input type="text" name="phone" id="phone" value="<?=$results['phone']?>"/>
						</div>
					</div> 
					<div class="control-group">
						<label class="control-label" for="tax">Tax:</label>
						<div class="controls">
							<input type="text" name="tax" id="tax" value="<?=$results['tax']?>"/>
						</div>
					</div> 
					<div class="control-group">
						<label class="control-label" for="email">Email:</label>
						<div class="controls">
							<input type="text" name="email" id="email" value="<?=$results['email']?>"/>
						</div>
					</div>                
	                    <input type="submit" name="submit" value="Save" />
                </form>
        	</div>
    	</div>
    	<!-- All Bootstrap JavaScript Files -->
       <script src="../inc/bootstrap/js/jquery.js"></script>
       <script src="../inc/bootstrap/js/bootstrap.js"></script>
	</body>
</html>